﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Routing;

namespace JobDescOnline.Presentation
{
    // Note: For instructions on enabling IIS6 or IIS7 classic mode, 
    // visit http://go.microsoft.com/?LinkId=9394801

    public class MvcApplication : System.Web.HttpApplication
    {
        public void RegisterRoutes(RouteCollection routes)
        {
            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

            routes.MapRoute(
                "Default", // Route name
                "{controller}/{action}/{id}", // URL with parameters
                new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults
            );

        }

        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();

            List<SelectListItem> items = new List<SelectListItem>();
            items.Add(new SelectListItem { Text = "Active", Value = "true" });
            items.Add(new SelectListItem { Text = "Not Active", Value = "false" });

            List<SelectListItem> locations = new List<SelectListItem>();
            locations.Add(new SelectListItem { Text = "Kantor Pusat", Value = "Kantor Pusat" });
            locations.Add(new SelectListItem { Text = "Kantor Cabang", Value = "Kantor Cabang" });

            List<SelectListItem> empty = new List<SelectListItem>();
            empty.Add(new SelectListItem { Text = "", Value = "" });

            Application["Active"] = items;
            Application["Location"] = locations;
            Application["ComboEmpty"] = empty;
            Application["ComboDepartment"] = JobDescOnline.Presentation.Models.Departments.DepartmentID;
            Application["ComboSection"] = JobDescOnline.Presentation.Models.Sections.SectionID;
            Application["ComboJobTitle"] = JobDescOnline.Presentation.Models.JobTitles.JobTitleID;
            Application["ComboCompetency"] = JobDescOnline.Presentation.Models.Competencies.CompetencyID;
            Application["ComboRole"] = JobDescOnline.Presentation.Models.Roless.RoleID;

            Models.JobDescDBEntities1 db = new Models.JobDescDBEntities1();
            Application["ParentMenu"] = db.Menus.Where(m => m.ParentID == 0 && m.Rowstatus == true).OrderBy(m => m.Sort);
            Application["MasterData"] = db.Menus.Where(m => m.ParentID == 1 && m.Rowstatus == true).OrderBy(m => m.Sort);
            Application["Setting"] = db.Menus.Where(m => m.ParentID == 7 && m.Rowstatus == true).OrderBy(m => m.Sort);

            RegisterRoutes(RouteTable.Routes);
        }
    }

    public class FilterData
    {
        public string column { get; set; }
        public string value { get; set; }
    }
}